<?php

namespace App\Admin\Repositories;

use App\Models\User as Model;
use Dcat\Admin\Repositories\EloquentRepository;

class User extends EloquentRepository
{
    /**
     * Model.
     *
     * @var string
     */
    protected $eloquentClass = Model::class;

    /**
     * 统计
     * @return mixed
     */
    public function statistics()
    {

        $data['all'] = [
            'name'  => '会员总数',
            'number'  => Model::query()->count(),
        ];
        $data['today'] = [
            'name'  => '今日新增',
            'number'  => Model::query()
                ->whereDate('created_at', date('Y-m-d'))
                ->count()
        ];
        $data['yesterday'] = [
            'name'  => '昨日新增',
            'number'  => Model::query()
                ->whereDate('created_at', date('Y-m-d',strtotime("-1 day")))
                ->count()
        ];

        return $data;
    }

}
